//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "adminActions\fn_TeleportModeAction.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_is_active","_action_id"];
PARAMS_1(_is_active);
_action_id = GVAR(TeleportAction);

TRACE_1("Input",ARR_2(_is_active,_action_id));
if (_action_id >= 0) then {
	if (!_is_active) then {
		player removeAction _action_id;
		GVAR(TeleportAction) = -1;
		TRACE_1("Action Removed",GVAR(TeleportAction));
	};
} else {
	if (_is_active) then {
		_action_id = player addAction [YELLOW_TEXT("Teleport Mode"),"tmf\core\addAction.sqf",[[],FUNC(teleportMode)],-5,false,true];
		GVAR(TeleportAction) = _action_id;
		TRACE_1("Action Added",GVAR(TeleportAction));
	};
};
if (!_is_active) then {
	if (GVAR(TeleportMode)) then {
		[QGVAR(LOG),["Teleport Mode Removed",name player, getPlayerUID player, GVAR(TeleportMode)],"all"] call FUNC(raiseEvent);
		[QGVAR(TeleportMode_EVT_ID), "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
	};
	GVAR(TeleportMode) = false;
};

TRACE_2("End",GVAR(TeleportMode),GVAR(TeleportAction));
TMFPROFILERSTOP;
